<template>
  <div>
    <h2 style="text-align:center">虚拟滚动列表</h2>
    <div class="container">
      <virtual-recycle-scroller :items="list">
        123
      </virtual-recycle-scroller>
    </div>
  </div>
</template>

<script>
  import VirtualRecycleScroller from './virtualRecycleScroller.vue'

  const axios = require('axios')
  // 模拟一个长列表
  // const list = []
  // for (let i = 0; i < 10000; i++) {
  //   list.push({
  //     age: i,
  //     label: `virtual-list ${i}`
  //   })
  // }

  export default {
    name: "virtualScroller",
    data() {
      return {
        list: []
      }
    },
    components: {
      VirtualRecycleScroller
    },
    created() {
      this.getList()
    },
    methods: {
      getList() {
        var config = {
          method: 'get',
          url: 'http://127.0.0.1:8000',
        }
        axios(config).then(res => {
          // console.log(res)
          this.list = res.data
        }).catch(error => {
          console.log(error)
        })
      }
    }
  }
</script>

<style scoped>
  .container {
    height: 350px;
    border: 1px solid #ccc;
  }
</style>
